from time import sleep

from basic.basic_page import BasicPage



class PageEntranceNewProductsAvailable(BasicPage):
    def new_product_list(self):
        """
        小米上新到购物车
        :return: PageServiceCart对象
        """
        from page.page_shopping.page_service import PageServiceCart
        value = "new UiSelector().className(\"android.view.ViewGroup\").instance(27)"
        self.click(value)
        sleep(10)
        value = "new UiSelector().className(\"android.widget.ImageView\").instance(8)"
        self.click(value)
        sleep(3)
        value = "new UiSelector().className(\"android.view.ViewGroup\").instance(51)"
        self.click(value)
        sleep(5)
        value = "new UiSelector().resourceId(\"com.xiaomi.shop.plugin.rank:id/detail_product_buy_tv\").instance(1)"
        self.click(value)
        sleep(5)
        return PageServiceCart()

    def new_calendar_update(self):
        pass


if __name__ == '__main__':
    from page.page_main import PageMain
    PageMain().goto_new_product_page().new_product_list().add_to_cart()
